package com.yh.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.Page;
import com.yh.Iservice.DeptService;
import com.yh.Iservice.EmployeeService;
import com.yh.Iservice.LimitService;
import com.yh.entity.Dept;
import com.yh.entity.Employee;
/**
 * 
<p>Title:LimitController</p>
<p>Describtion:方</p>
<p>Company:云和</p>

 * @author Administrator
 *@date 2018年11月7日
 */
@Controller
@RequestMapping("limit")
public class LimitController {

	@Autowired
	private LimitService limitService;
	@Autowired 
	private EmployeeService employeeService;
	@Autowired
	private DeptService deptService;
	@RequestMapping("findlist")
	public String findList(Model model){
		/*List<Employee> employees=employeeService.finlist();
		model.addAttribute("emp",employees);
		//查询部门
		List<Dept> depts=deptService.findall();
		model.addAttribute("depts",depts);
		return "/WEB-INF/view/limit";*/
		
		//使用插件分页
		return "/WEB-INF/view/limit-new";
	}
	/**
	 * 分页
	 */
	
	@RequestMapping("getEmployeePage")
	@ResponseBody
	public Map getEmployeePage(int pageNum,int pageSize){
		
		Map map=new HashMap<>();
		map.put("pageSize", pageSize);
		map.put("pageNum", pageNum);
		Page page=limitService.getEmployeePage(map);
		map.put("page", page);
		map.put("totalPage", page.getPages());
		return map;
	}
	
}
